<?php
require_once ('../lib/config.php');
require_once ('../lib/facebook.php');
require_once ('../lib/friends.php');
require_once ('../lib/friend.php');
require_once ('../lib/test.php');
require_once ('../../simpletest/autorun.php');
require_once ('../lib/init.php');
require_once ('../data_sample/mockup_data_like.php');

class TestFunc_processFriendLike extends UnitTestCase {
    
    function setUp(){
        global $login_button,$facebook;
        
        if(isLoggedIn()){
            try{
                $me = getOneself();
            }catch(Exception $e){
                print($login_button);
                exit();
            }
        }
    }

/////////////////////////
//FRIEND LIKE CASES
//NOTE: no need to specify the kind of posts here
//Case5: A friend liked my post (regardless of where it is)
    function test_case5(){ 
        global $likeCase5;
        $data = $likeCase5;
        $friends = array();
        
        processFriendLike($friends, $data, "FRIEND_LIKE_ON_STATUS_FLAG");
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends),1);
        
        $friend = $friends['100000416787478'];
        $this->assertEqual($friend->getNumberOfData("FRIEND_LIKE_ON_STATUS_FLAG"), 1);
    }
//    5.1: A friend liked my posts
    function test_case51(){ 
        global $likeCase51;
        $data = $likeCase51;
        $friends = array();
        
        processFriendLike($friends, $data, "FRIEND_LIKE_ON_STATUS_FLAG");
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends),1);
        
        $friend = $friends['100000416787478'];
        $this->assertEqual($friend->getNumberOfData("FRIEND_LIKE_ON_STATUS_FLAG"), 2);
    }
//    5.2: Two friends liked my post
    function test_case52(){ 
        global $likeCase52;
        $data = $likeCase52;
        $friends = array();
        
        processFriendLike($friends, $data, "FRIEND_LIKE_ON_STATUS_FLAG");
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends),2);
        
        $friend = $friends['100000416787478'];
        $this->assertEqual($friend->getNumberOfData("FRIEND_LIKE_ON_STATUS_FLAG"), 1);
        $friend = $friends['100000525262538'];
        $this->assertEqual($friend->getNumberOfData("FRIEND_LIKE_ON_STATUS_FLAG"), 1);
    }
//    5.3: Two friends liked my posts
    function test_case53(){ 
        global $likeCase53;
        $data = $likeCase53;
        $friends = array();
        
        processFriendLike($friends, $data, "FRIEND_LIKE_ON_STATUS_FLAG");
        
        $this->assertNotNull($friends);
        $this->assertTrue(is_array($friends));
        $this->assertFalse(empty($friends));
        
        $this->assertEqual(count($friends),2);
        
        $friend = $friends['100000416787478'];
        $this->assertEqual($friend->getNumberOfData("FRIEND_LIKE_ON_STATUS_FLAG"), 3);
        $friend = $friends['100000525262538'];
        $this->assertEqual($friend->getNumberOfData("FRIEND_LIKE_ON_STATUS_FLAG"), 2);
    }
    
}
?>
